<template>
  <div>
    <div class="breadcrumb-box">
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item>我的积分</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="integral container">
      <left-nav-bar :active="active"></left-nav-bar>
      <div class="right" v-if="loading">
        <div class="inter">
          <div class="int-top">
            <div>我的积分：</div>
            <div>{{ info.integral }}</div>
          </div>
          <div style="height: 40px"></div>
        </div>
        <el-tabs v-model="activeName" @tab-click="handleClick">
          <el-tab-pane label="积分明细" name="first">
            <el-table :data="integralList" border style="width: 100%" v-if="integralList.length">
              <el-table-column prop="add_time" align="center" label="日期" width="180"></el-table-column>
              <el-table-column prop="name" align="center" label="收入/支出" width="180">
                <template slot-scope="scope">
                  <div class="num" v-if="scope.row.pm==1">+{{scope.row.number}}</div>
                  <div class="num add" v-else>-{{scope.row.number}}</div>
                </template>
              </el-table-column>
              <el-table-column prop="mark" label="备注"></el-table-column>
            </el-table>
            <div class="nodata" v-show="integralList.length == 0">
              <img :src="$global.Image.noIntegral" />
            </div>
            <div class="pagination-box" v-if="integralList.length!==0">
              <el-pagination
                background
                layout="prev, pager, next"
                @current-change="pageChange"
                :page-size="where.limit"
                :total="count"
              ></el-pagination>
            </div>
          </el-tab-pane>
          <el-tab-pane label="积分规则" name="second">
            <div class="rule">
              <div>1、充值金额全部进入用户账户的钱包。钱包不支持提现。</div>
              <div>2、使用钱包支付时，与平台满减或优惠券等优惠不冲突。</div>
              <div>3、支付时只能选择使用钱包支付或其他支付方式，钱包支付不能与其他支付方式合并使用。</div>
            </div>
          </el-tab-pane>
        </el-tabs>
      </div>
    </div>
    <div style="height: 200px"></div>
  </div>
</template>

<script>
import leftNavBar from "@components/leftNavBar";
import { getIntegralList, postSignUser } from "@api/user";

export default {
  name: "integral",
  data() {
    return {
      activeName: "first",
      active: 6,
      info: "",
      integralList: [],
      where: {
        page: 1,
        limit: 15
      },
      count: "",
      loading: false
    };
  },
  methods: {
    getIntergralInfo() {
      let that = this;
      postSignUser(that.data).then(
        res => {
          that.info = res.data;
          this.loading = true;
        },
        err => {
          // that.$dialog.message(err.msg);
        }
      );
    },
    getIntegral() {
      let that = this;
      getIntegralList(that.where).then(
        res => {
          that.integralList = res.data || [];
          that.count = res.count;
        },
        err => {
          that.$dialog.message(err.msg);
        }
      );
    },
    pageChange(value) {
      this.where.page = value;
      this.getIntegral();
    }
  },
  components: {
    leftNavBar
  },
  mounted() {
    this.getIntergralInfo();
    this.getIntegral();
  }
};
</script>

<style scoped  rel="stylesheet/scss" lang="scss" scoped>
$color: #DA213D;
.integral {
  margin: 0 auto;
  display: flex;
  .right {
    width: 1000px;
    margin-left: 32px;
    ::v-deep .el-tabs__item{
      padding: 0 10px;
    }
    ::v-deep .el-tabs__item.is-active{
      color: $color;
    }
    ::v-deep .el-tabs__active-bar {
      background-color: $color;
    }
    ::v-deep .el-table {
      font-size: 15px;
    }
    ::v-deep .el-table th {
      background-color: #f5f5f5;
    }
    .num{
      color: #4caf50;
      font-size: 16px;
      font-weight: 600;
    }
    .add{
      color: $color;
    }
    .rule {
      padding: 20px 10px;
      font-size: 15px;
      color: #666;
      line-height: 2;
    }
    .inter {
      .int-top {
        background: rgba($color: #DA213D, $alpha: 0.2);
        width: 100%;
        height: 90px;
        display: flex;
        align-items: center;
        color: #014a97;
        font-weight: 600;

        > div:nth-of-type(1) {
          font-size: 17px;
          padding-left: 40px;
        }

        > div:nth-of-type(2) {
          font-size: 30px;
          padding-left: 17px;
        }
      }
    }
  }
}
.nodata {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
</style>
